<template>
  <div class="school">
    <h3>学校名称：{{ name }}</h3>
    <h3>地址：{{ address }}</h3>
  </div>
</template>

<script>
export default {
  name: "School",
  data() {
    return {
      name: "福州大学",
      address: "福州洪山桥",
    };
  },
  methods:{
    demo(value){
      console.log("school组件收到数据",value);
    }
  },
  mounted(){
    this.$bus.$on("demo",this.demo)//可以用箭头函数替代
  },
  beforeDestroy(){
    this.$bus.$off("demo")//解绑
  }
};
</script>

<style scoped>
.school {
  background-color: red;
  padding: 5px;
}
</style>